<%--
    Document   : formTest
    Created on : 31.12.2012, 10:31:08
    Author     : Martin Zmítko <martin.zmitko@gmail.com>
--%>

<%@page import="cz.uhk.ppro.response.model.Test"%>
<%@ include file="/WEB-INF/jsp/header.jsp" %>
<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>

        <!--Druhá část formuláře - generování testů  -->
        <form:form class="form-horizontal" modelAttribute="testData" action="tests_questions${test_edit?'_edit':''}.do">
            <c:if test="${testData.id != 0}">
                <div class="control-group">
                    <label class="control-label" for="inputName"><spring:message code="form.id" />:</label>
                    <div class="controls">
                        <form:hidden path="id" readonly="true" /> <span>${testData.id}</span>
                    </div>
                </div>
            </c:if>
            
            <c:if test="${testData.id != 0}"> <h2>Přidání/Editace testových tázek - ${testData.name}</h2> </c:if>       
                       
            <!--TYP 1: a,b,c,d -->
            <c:if test="${testData.types.id == 1}">

                <c:forEach items="${testData.questions}" var="q" varStatus="itemsRowQuestion">
                    <div class="control-group">
                        <label class="control-label" for="inputQuestion">Otázka ${itemsRowQuestion.index+1}:</label>
                        <div class="controls">
                             <form:textarea style="width:500px;" path="questions[${itemsRowQuestion.index}].name" id="inputQuestion" />
                        </div>
                    </div>
                    <div class="control_test">
                        <c:forEach items="${q.answers}" var="a" varStatus="itemsRowAnswer">
                            <div class="control-group answer-item">
                                <label class="answer-label" for="inputAnswer">Odpověď ${itemsRowAnswer.index +1}:</label>
                                <form:input path="questions[${itemsRowQuestion.index}].answers[${itemsRowAnswer.index}].name" id="inputAnswers" />
                                <form:checkbox path="questions[${itemsRowQuestion.index}].answers[${itemsRowAnswer.index}].isCorrect" id="inputCorrectAnswers" />
                            </div>
                        </c:forEach>
                    </div>
                    <br /><br />
                </c:forEach>
            </c:if>

            <!--TYP 2: ano/ne -->
            <c:if test="${testData.types.id == 2}">

                <c:forEach items="${testData.questions}" var="q" varStatus="itemsRowQuestion">
                    <div class="control-group">
                        <label class="control-label" for="inputQuestion">Otázka ${itemsRowQuestion.index+1}:</label>
                        <div class="controls">
                             <form:textarea style="width:500px;" path="questions[${itemsRowQuestion.index}].name" id="inputQuestion" />
                        </div>
                    </div>
                    <div class="control_test">
                        <div class="control-group">
                                  
                                        <div class="control-group answer-item">
                                             <label  path="questions[${itemsRowQuestion.index}].answers[0].name" id="inputAnswers" value="ANO" /> ANO: </label>
                                             <form:checkbox path="questions[${itemsRowQuestion.index}].answers[0].isCorrect" id="inputCorrectAnswers" />
                                             
                                             <label path="questions[${itemsRowQuestion.index}].answers[1].name" id="inputAnswers"  value="NE" /> NE: </label>
                                             <form:checkbox path="questions[${itemsRowQuestion.index}].answers[1].isCorrect" id="inputCorrectAnswers" />
                                        </div>
                                    
                         </div>
                    </div>
                    <br /><br />
                </c:forEach>
            </c:if>
             

            
            <br />
            <div class="control-group">
                <div class="controls">
                    <input type="submit" value="<spring:message code="form.saveTest" />" class="myBtn" />
                </div>
            </div>
        </form:form>

<%@ include file="/WEB-INF/jsp/footer.jsp" %>